package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Praise;
import com.sk.bilibili.dto.PraiseInfo;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.PraiseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 邵康
 * @date 2021/11/25 12:34
 */
@CrossOrigin
@RestController
@RequestMapping("/praise")
@Api(tags = "点赞")
public class PraiseController {

    @Autowired
    private PraiseService praiseService;

    @ApiOperation("切换点赞状态  返回最终是否点赞  类型  targetId  必须")
    @PostMapping("/switchPraise")
    public R<Boolean> switchPraise(@RequestBody Praise praise) {
        return praiseService.switchPraise(praise);
    }

    @ApiOperation("add")
    @PostMapping("/add")
    public R<Void> add(@RequestBody Praise praise) {
        return praiseService.add(praise);
    }

    @ApiOperation("deleteRes")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return praiseService.delete(id);
    }

    @ApiOperation("update")
    @PostMapping("/update")
    public R<Void> update(@RequestBody Praise praise) {
        return praiseService.update(praise);
    }

    @ApiOperation("分页获取点赞视频信息 包含番剧 与 视频")
    @PostMapping("/getPraiseVideo")
    public R<IPage<Praise>> getPraiseVideo(@RequestBody PraiseInfo praiseInfo) {
        return praiseService.getPraiseVideo(praiseInfo);
    }

}
